//
//  DDDExpressFeedViewVC.m
//  DDDDemo
//
//  Created by mu on 2020/7/23.
//  Copyright © 2020 summer. All rights reserved.
//

#import "DDDExpressFeedViewVC.h"
#import <DDDAdSdk/DDDAdSdk.h>

@interface DDDExpressFeedViewVC ()<DDDNativeAdsManagerDelegate> 
@property (strong, nonatomic) DDDNativeAdsManager *nativeExpressAdManager;
@end

@implementation DDDExpressFeedViewVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    
    //具体类型需要对应具体的尺寸
    /**
            DDDNativeAdsManagerType_VerticalScreenVedio          //竖屏视频模板  宽高比  0.56
            DDDNativeAdsManagerType_RunningHorse1                 //跑马灯信息流1  宽高比  1.78
            DDDNativeAdsManagerType_RunningHorse2                //跑马灯信息流2   宽高比  1.78
            DDDNativeAdsManagerType_HorizontalScreenVedio     //横版视频模板    宽高比  1.78
            DDDNativeAdsManagerType_UpTextDownImage           //上文下图模板    宽高比  1.78
            DDDNativeAdsManagerType_UpTextDownImage2         //上文下图附加创意模板   宽高比  1.78
            DDDNativeAdsManagerType_UpTextDownFloating        //上文下浮层模板     宽高比  1.78
            DDDNativeAdsManagerType_TextFloating                      //文字浮层模板     宽高比  1.78
            DDDNativeAdsManagerType_LeftImageRightText          //左图右文模板     宽高比  1.52
            DDDNativeAdsManagerType_LeftTextRightImage          //左文右图模板     宽高比  1.52
            DDDNativeAdsManagerType_ThreeImage                      //三图模板            宽高比  1.52
     
     
             DDDNativeAdsManagerTXType_UpImageDownText                 高度自适应
             DDDNativeAdsManagerTXType_UpTextDownImage                 高度自适应
             DDDNativeAdsManagerTXType_DoubleImageText                 高度自适应
             DDDNativeAdsManagerTXType_Image_1280_720                高度自适应
             DDDNativeAdsManagerTXType_LeftImageRightText                 高度自适应
             DDDNativeAdsManagerTXType_LeftTextRightImage                高度自适应
             DDDNativeAdsManagerTXType_Image_800_1200              高度自适应
             DDDNativeAdsManagerTXType_ThreeImage               高度自适应
             DDDNativeAdsManagerTXType_TextViewUpTextDownImage              高度自适应
             DDDNativeAdsManagerTXType_TextViewUpImageDownText             高度自适应
             DDDNativeAdsManagerTXType_TextViewImage             高度自适应
             DDDNativeAdsManagerTXType_Image_1080_1920               高度自适应
     */
    switch (self.type) {
        case 0:
        {
            CGFloat heigh = width / 0.56;
            self.navigationItem.title = @"竖屏视频模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_VerticalScreenVedio];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 1:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"跑马灯信息流1";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_RunningHorse1];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 2:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"跑马灯信息流2";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_RunningHorse2];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 3:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"横版视频模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_HorizontalScreenVedio];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 4:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"上文下图模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_UpTextDownImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 5:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"上文下图附加创意模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_UpTextDownImage2];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 6:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"上文下浮层模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_UpTextDownFloating];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 7:
        {
            CGFloat heigh = width / 1.78;
            self.navigationItem.title = @"文字浮层模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_TextFloating];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 8:
        {
            CGFloat heigh = width / 1.52;
            self.navigationItem.title = @"左图右文模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_LeftImageRightText];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 9:
        {
            CGFloat heigh = width / 1.52;
            self.navigationItem.title = @"文字浮层模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_LeftTextRightImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 10:
        {
            CGFloat heigh = width / 1.52;
            self.navigationItem.title = @"三图模板";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerType_ThreeImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 11:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"上图下文";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_UpImageDownText];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 12:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"上文下图";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_UpTextDownImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 13:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"双图双文";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_DoubleImageText];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 14:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"纯图片（横屏）";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_Image_1280_720];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 15:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"左图右文";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_LeftImageRightText];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 16:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"左文右图";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_LeftTextRightImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 17:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"三小图";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_ThreeImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 18:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"文字浮层(上文下图)";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_TextViewUpTextDownImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 19:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"文字浮层(上图下文)";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_TextViewUpImageDownText];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 20:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"单图文";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_TextViewImage];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
        case 21:
        {
            CGFloat heigh = width / 1.52;//主要是宽度  高度自适应
            self.navigationItem.title = @"纯图片(竖屏)";
            self.nativeExpressAdManager = [[DDDNativeAdsManager alloc]initWithAdSize:CGSizeMake(width, heigh) andAdType:DDDNativeAdsManagerTXType_Image_1080_1920];
            self.nativeExpressAdManager.delegate = self;
            [self.nativeExpressAdManager loadData:1];
        }
            break;
            
        default:
            break;
    }
}


/**
 * 视图成功加载的回调
 */
- (void)nativeExpressAdSuccessToLoadViews:(NSArray<__kindof DDDNativeExpressAdView *> *)views {
    if (views.count > 0) {
        DDDNativeExpressAdView *expressView = (DDDNativeExpressAdView *)views.firstObject;
        expressView.rootViewController = self;
        [expressView render];
        expressView.frame = CGRectMake(0.0, 100.0, expressView.bounds.size.width, expressView.bounds.size.height);
        [self.view addSubview:expressView];
    }
    NSLog(@"%s",__func__);
}
/**
 * 视图加载失败的回调
 */
- (void)nativeExpressAdFailToLoadError:(NSInteger)errorCode {
    NSLog(@"summer--%ld",errorCode);
    NSLog(@"%s",__func__);
}

/**
 * 广告视图无法呈现时的回调
 */
- (void)nativeExpressAdViewRenderFailRrror:(NSInteger)errorCode {
    NSLog(@"summer--%ld",errorCode);
    NSLog(@"%s",__func__);
}

/**
 * 视图即将呈现时的回调
 */
- (void)nativeExpressAdViewWillShow {
    NSLog(@"%s",__func__);
    
}

/**
 * 点击视图的回调
 */
- (void)nativeExpressAdViewDidClick {
    NSLog(@"%s",__func__);
}


/**
 * 用户点击不喜欢
 * @param filterwords : 原因数组
 */
- (void)nativeExpressAdViewDislikeWithReason:(NSArray<NSString *> *_Nullable)filterwords {
    NSLog(@"%s",__func__);
}


/// 此方法在关闭另一个控制器时调用
- (void)nativeExpressAdViewDidCloseOtherController {
    NSLog(@"%s",__func__);
}
@end
